<%@page import="com.baoyanghui.common.Constants"%>
<%@page import="net.sf.json.JSONArray"%>
<%@page import="java.util.List"%>
<%@page import="com.baoyanghui.model.MerchantType"%>
<%@page import="com.baoyanghui.common.Utils"%>
<%@page import="com.baoyanghui.common.DataChanger"%>
<%@page import="com.baoyanghui.config.Configs"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@page import="com.baoyanghui.model.Merchant"%>
<%@page import="net.sf.json.JSONObject"%>
<%@page import="com.baoyanghui.common.InterfaceAccess"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	if (Utils.empty((String)request.getSession().getAttribute(Configs.SESSION_USER_ID))
			|| (Constants.USER_TYPE_CUSTOMER == (Integer)request.getSession().getAttribute(Configs.SESSION_USER_TYPE))) {
		response.getWriter().print("<script type='text/javascript'>\n");
		response.getWriter().print("window.location.href='" + request.getContextPath() + "/index.jsp';\n");
		response.getWriter().print("</script>\n");
		response.getWriter().flush();
		return;
	}

	JSONObject merchantTypes = null;
	MerchantType merchantType = null;
	List<MerchantType> merchantTypeList = null;
	Map<String, String> params = new HashMap<String, String>();
	
	try {
		request.setCharacterEncoding("UTF-8");
		
		merchantTypes = InterfaceAccess.callInterface("/get_merchant_types", params);
		merchantTypeList = (List<MerchantType>)JSONArray.toList(merchantTypes.getJSONArray("resultData"), MerchantType.class);
	} catch (Exception e) {
	}
%>
<script type="text/javascript" src="../js/register.js"></script>
<script type="text/javascript" src="../js/place_manage.js"></script>
<div style="height: 34px; padding-left: 20px; padding-top: 5px; border-bottom: 1px solid gray;">
	<img class="pointer fade_effect" src="../image/btn_basic_info_off.png" onclick="showMerchantInfoTab();"/>
	<img class="pointer fade_effect" src="../image/btn_place_manage_on.png"/>
	<img class="pointer fade_effect" src="../image/btn_place_request_auth_off.png" onclick="showPlaceRequests();"/>
</div>
<div style="padding-left: 15px; padding-top: 15px; font-size: 13pt; font-weight: bold;">自主经营场所</div>
<div id="div_place_list">
</div>
<div style="padding-left: 40px; padding-top: 20px;">
	<img class="pointer fade_effect" src="../image/btn_add_place.png" onclick="toggleAddPlaceDiv();"/>
</div>
<form id="div_add_place" style="margin: 5px; padding-left: 40px; display: none; background: #eae5d9; line-height: 50px;">
	<div style="width: 500px; padding-top: 20px; float: left;">
		<label>*场所名称：</label><input type="text" name="place_name" id="place_name" maxlength="20" onblur="checkPlaceName();"/><br/>
		<label>*场所联系人：</label><input type="text" name="place_linkman" id="place_linkman" maxlength="20" onblur="checkPlaceLinkMan();"/><br/>
		<label>*固定电话：</label><input type="text" id="office_phone" name="office_phone" maxlength="20" onblur="checkOfficePhone();"/><br/>
		<label>*营业项目：</label><br/>
		<div style="width: 315px; padding-left: 30px; line-height: 30px;">
<%
	for (int i = 0; merchantTypeList != null && i < merchantTypeList.size(); i++) {
		merchantType = merchantTypeList.get(i);
%>
			<div style="width: 150px; float: left; font-size: 13pt;">
				<div style="width: 17px; height: 30px; float: left; cursor: pointer; background: url('<%= request.getContextPath() %>/image/radio_gray_unselected.png') center no-repeat;" 
					id="item_<%= merchantType.getTypeId() %>" onclick="toggleBusinessItem('<%= merchantType.getTypeId() %>');"></div>
				<div style="width: 80px; height: 16px; padding-left: 5px; float: left;">
					<%= merchantType.getTypeName() %>
				</div>
				<div style="clear: both;"></div>
			</div>
<%
	}
%>
			<div style="clear: both;"></div>
		</div>
	</div>
	<div style="width: 400px; padding-top: 20px; float: left;">
		<label>*场所地址：</label><input type="text" name="address" id="address" maxlength="50" onblur="checkPlaceAddress();"/><br/>
		<label>靠近：</label><input type="text" style="width: 105px;" name="road_nearby" id="road_nearby" maxlength="50"/>路
		<img src="../image/btn_map_label.png" align="top" style="margin-top: 10px;"/>
		<br/>
		<label>手机号：</label><input type="text" name="mobile" id="mobile" maxlength="20" onblur="checkMobile();"/><br/>
		<object id="flash_upload" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540002" align="top"
			type="application/x-shockwave-flash" width="119" height="34" style="margin-left: 30px;">
		  <param name="movie" value="<%= request.getContextPath() %>/flash/upload.swf?ws_context=<%= InterfaceAccess.InterfaceContext %>" />
		  <param name="quality" value="high" />
		  <param name="wmode" value="transparent"/>
		  <embed src="<%= request.getContextPath() %>/flash/upload.swf?ws_context=<%= InterfaceAccess.InterfaceContext %>" 
		  	wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" 
		  	allowScriptAccess="sameDomain" allowFullScreen="false"
		  	type="application/x-shockwave-flash" width="119" height="34">
		  </embed>
		</object><br/>
		<img id="img_place" src="" width="165px" height="90px" style="margin-left: 30px;"/><br/>
	</div>
	<div style="clear: both;"></div>
	<div align="left" style="margin-top: 20px;">
		<img class="pointer fade_effect" src="<%= request.getContextPath() %>/image/btn_save_new_place.png" align="top"
			 onclick="addMerchantPlace();"/>
		<a class="blue" style="font-size: 13pt;" href="javascript: toggleAddPlaceDiv();">取消</a>
	</div>
	<span class="error_message" id="error_message_add_place"></span>
</form>
<div style="margin: 15px 5px; border-bottom: 1px dashed gray;"></div>
<div style="padding-left: 15px; padding-top: 15px; font-size: 13pt; font-weight: bold;">合作经营场所</div>
<div id="div_place_coop_list">
</div>
<div style="padding-left: 40px; padding-top: 20px;">
	<img class="pointer fade_effect" src="../image/btn_add_place_coop.png" onclick="toggleAddPlaceCoopDiv();"/>
</div>
<form id="div_add_place_coop" style="width: 450px; margin: 5px; padding-left: 40px; display: none; background: #eae5d9; line-height: 50px;">
	<div id="div_available_place_list" style="padding-top: 15px;">
		<select id="slt_place_id">
			<option value="">请选择</option>
		</select>
	</div>
	<div align="left" style="margin-top: 20px;">
		<img class="pointer fade_effect" src="<%= request.getContextPath() %>/image/btn_save_new_place.png" align="bottom"
			 onclick="addMerchantPlaceCoop();"/>
		<a class="blue" style="font-size: 13pt;" href="javascript: toggleAddPlaceCoopDiv();">取消</a>
	</div>
	<span class="error_message" id="error_message_add_place_coop"></span>
</form>